package com.zc.action;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.zc.dao.impl.ArticleDaoImpl;
import com.zc.model.Article;

public class ArticleEditAction extends ActionSupport implements ModelDriven<Article> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Article article = new Article();

	@Override
	public String execute() throws Exception {

		System.out.println("ArticleEdit输出articl的内容------------------"+article.toString());
		ArticleDaoImpl articleDao = new ArticleDaoImpl();
		Article tempArticle = articleDao.getArticle(article);
		ActionContext context = ActionContext.getContext();

		Map<String, Object> request = (Map<String, Object>) context.get("request");
		request.put("article", tempArticle);

		System.out.println(article.toString());
		return SUCCESS;
	}

	@Override
	public Article getModel() {
		// TODO Auto-generated method stub
		return this.article;
	}

	public Article getArticle() {
		return article;
	}

	public void setArticle(Article article) {
		this.article = article;
	}

}
